/*
 * @Author: silence silence9685@163.com
 * @Date: 2023-04-21 11:37:03
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2024-04-15 14:00:41
 * @FilePath: \lenercom_bluetooth_app\lib\pages\Mine\AccountManager\View\AMTitleView.dart
 * @Description: 账号管理-item-内容
 */
import 'package:flutter/material.dart';
import '../../../common/widgets/uploadPics/UpLoadPicsWidget.dart';
import '../../../utils/color/ColorUtils.dart';
import 'package:sil_base_widget_package/sil_base_widget_package.dart';

class AMItemContentView extends StatelessWidget {
  final String? title;
  final String? imgPath;
  final String? subTitle;
  final EdgeInsets? margin;

  /// 是否隐藏右侧箭头，默认不隐藏
  final bool? hideRightArrow;
  final void Function()? onTapFunc;

  /// 右侧显示的View
  final Widget? rightView;
  final double? titleFontSize;
  final FontWeight? titleFontWidget;

  /// 删掉右侧箭头,默认不删除
  final bool? delRightArrow;

  /// 返回上传图片的本地地址
  final dynamic Function(List<String>)? rebackResultFunc;

  const AMItemContentView(
      {this.title,
      this.imgPath,
      this.subTitle,
      this.margin,
      this.hideRightArrow = false,
      this.onTapFunc,
      this.rightView,
      this.titleFontSize,
      this.titleFontWidget,
      this.rebackResultFunc,
      this.delRightArrow = false,
      Key? key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SilEmptyButton(
      useConstrained: true,
      onTapFunc: this.onTapFunc,
      margin: this.margin,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          /// 左边标题
          SilText(this.title,
              fontSize: this.titleFontSize ?? 14.sp,
              color: ColorUtils.color_font_main,
              fontWeight: this.titleFontWidget ?? FontWeight.w500,
              textAlign: TextAlign.left),

          /// 右侧内容
          this.rightView ?? righView()
        ],
      ),
    );
  }

  righView() {
    return Row(
      children: [
        if (this.imgPath != null)
          UpLoadPicsWidget(
              spacing: 0,
              crossSpacing: 0,
              maxNum: 1,
              itemHeight: 24.w,
              itemWidth: 24.w,
              radius: 12.w,
              rebackResultFunc: this.rebackResultFunc,
              placeholderWidget: SilImage(
                this.imgPath,
                height: 24.w,
                width: 24.w,
                radius: 12.w,
              )),
        if (this.subTitle != null)
          SilText(this.subTitle,
              fontSize: 14.sp,
              color: ColorUtils.color_font_minor,
              textAlign: TextAlign.right),
        // 右侧箭头
        if (this.delRightArrow == false)
          Container(
              margin: EdgeInsets.only(left: 10.w),
              width: 24.w,
              height: 24.w,
              child: (this.hideRightArrow == false)
                  ? SilImage('imgs/personal/list_icon_arrow@3x.png')
                  : Container())
      ],
    );
  }
}
